<template>
  <div class="top">
    <div class="left">
      <span class="lbtn" @click="goHome">首页</span>
    </div>
    <div class="center">
      <div class="title">智慧旅游可视化大数据平台</div>
    </div>
    <div class="right">
      <span class="rbtn">统计报告</span>
      <span class="time">{{ time }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { useRouter } from 'vue-router';
import dayjs from 'dayjs';
const $router = useRouter();
const goHome = () => {
  // 处理点击首页按钮的逻辑
  $router.push('/home');
};
//存储当前时间
let time = ref(dayjs(new Date()).format('YYYY年MM月DD日 hh:mm:ss'));
const timer = ref(0);
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = dayjs(new Date()).format('YYYY年MM月DD日 hh:mm:ss');
  }, 1000);
});

onBeforeUnmount(() => {
  clearInterval(timer.value);
});
</script>
<style scoped lang="scss">
.top {
  width: 100%;
  height: 40px;
  display: flex;

  .left {
    flex: 1.5;
    background: url('@/assets/images/screen_images/dataScreen-header-left-bg.png') no-repeat;
    background-size: cover;

    .lbtn {
      width: 150px;
      height: 40px;
      float: right;
      cursor: pointer;
      background: url('@/assets/images/screen_images/dataScreen-header-btn-bg-l.png') no-repeat;
      background-size: 100% 100%;
      text-align: center;
      line-height: 40px;
      color: #29fcff;
      font-size: 20px;
    }
  }

  .center {
    flex: 2;

    .title {
      width: 100%;
      height: 74px;
      background: url('@/assets/images/screen_images/dataScreen-header-center-bg.png') no-repeat;
      background-size: 100% 100%;
      line-height: 74px;
      text-align: center;
      font-size: 30px;
      color: #29fcff;
    }
  }

  .right {
    flex: 1.5;
    background: url('@/assets/images/screen_images/dataScreen-header-right-bg.png') no-repeat;
    background-size: cover;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .rbtn {
      width: 150px;
      height: 40px;
      float: left;
      cursor: pointer;
      background: url('@/assets/images/screen_images/dataScreen-header-btn-bg-r.png') no-repeat;
      background-size: 100% 100%;
      text-align: center;
      line-height: 40px;
      color: #29fcff;
      font-size: 20px;
    }

    .time {
      color: #29fcff;
      font-size: 20px;
      margin-right: 10px;
    }
  }
}
</style>
